package com.cn.controller;

import com.cn.feign.UserFeign;
import com.cn.vo.PostUserEntityReqVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @program: springcloud-example
 * @description:
 * @author:
 * @create: 2018-06-15 15:55
 **/
@RestController
public class FeignController {

    @Autowired
    private LoadBalancerClient loadBalancerClient;

    @Autowired
    private RestTemplate restTemplate;

    @Autowired
    private UserFeign userFeign;

    @GetMapping("/getNullUser")
    @ResponseBody
    public String getNullUser() {
        return userFeign.getNullUser();
    }

    @GetMapping("/getUser")
    @ResponseBody
    public String getUser(@RequestParam String name) {
        return userFeign.getUser(name);
    }

    @PostMapping("/postNullUser")
    @ResponseBody
    public String postNullUser() {
        return userFeign.postNullUser();
    }

    @PostMapping("/postUser")
    @ResponseBody
    public String postUser(@RequestBody String name) {
        return userFeign.postUser(name);
    }

    @PostMapping("/postUserEntity")
    @ResponseBody
    public String postUserEntity(@RequestBody PostUserEntityReqVO reqVO) {
        return userFeign.postUserEntity(reqVO);
    }
}
